import { createBrowserRouter } from "react-router-dom";
import App from '../App'
import { lazy } from "react";

const Home = lazy(() => import('../pages/home'))
const All = lazy(() => import('../pages/all'))
const Old = lazy(() => import('../pages/old'))
const New = lazy(() => import('../pages/new'))
const Error = lazy(() => import('../pages/404'))

export const elses = [
    {
        path: 'home',
        element: <Home />,
        title: '类型',
        children: [
            {
                path: '/home/all',
                element: <All />,
                title: '全部类型',
            },
            {
                path: '/home/old',
                element: <Old />,
                title: '都市',
            },
            {
                path: '/home/new',
                element: <New />,
                title: '玄幻',
            }
        ]
    }
]

const routes = [
    {
        path: '/',
        element: <App />,
        children: elses
    },
    {
        path: '*',
        element: <Error />
    }
]

// eslint-disable-next-line react-refresh/only-export-components
export default createBrowserRouter(routes)